<!-- 库位组件 -->
<template>
    <div class="warehousePanel">
        <nut-popup position="bottom" closeable round v-model:visible="showRound.state">
            <div class="warehousePanel_title">
                库位
            </div>
            <div class="warehousePanel_search">
                <nut-searchbar v-model="searchValue">
                    <template v-slot:rightin>
                        <Search2 />
                    </template>
                </nut-searchbar>
            </div>
            <div class="warehousePanel_content">
                <nut-radio-group v-model="radioVal">
                    <nut-tabs style="height:520rpx" v-model="tabVal" direction="vertical" title-scroll>
                        <nut-tab-pane v-for="item in WarehouseInfo" :title="item.warehouseName">
                            <div v-for="t in item.childHouseList" class="warehousePanel_content_pane_list"
                                @click="chooseHouse(t)">
                                <div style="width:500rpx;display: flex;justify-content: space-between;margin-bottom: 10px;">
                                    <div class="warehousePanel_content_item_title">
                                        {{ t.warehouseName }}
                                    </div>
                                    <nut-radio :label="t.warehouseNo"></nut-radio>
                                </div>

                                <div
                                    style="margin-bottom:5px;padding-right:10px;font-size:24rpx;color:#666666;width:460rpx;display: flex;justify-content: space-between;">
                                    <div>
                                        <span>仓库代码：{{ t.warehouseCode }}</span>
                                    </div>
                                    <div>
                                        <span>库位：{{ t.warehouseNo }}</span>
                                    </div>
                                </div>
                                <div style="font-size:24rpx;color:#666666;">
                                    级别码：{{ t.levelCode }}
                                </div>



                            </div>

                        </nut-tab-pane>
                    </nut-tabs>
                </nut-radio-group>
            </div>

            <div class="warehousePanel_determine">
                <nut-button @click="determine" block type="info">确 定</nut-button>
            </div>

        </nut-popup>
    </div>
</template>

<script setup lang="ts">
import { onMounted, defineComponent, getCurrentInstance, reactive, ref } from 'vue';
import { Search2 } from '@nutui/icons-vue-taro';
import { getWarehouse } from '@/@api/audit.ts'
import Taro from '@tarojs/taro';

const radioVal = ref('A1')
const tabVal = ref('0')
const customCategory = [
    {
        "catId": "A1",
        "catName": "电视机",
        'title': 'B库(29-34)|广州发货仓',
        code: 'F_GFHC',
        hos: '0002',
        lev: '0001'
    },
    {
        "catId": "A2",
        "catName": "食品",
        'title': 'B库(29-34)|广州发货仓',
        code: 'F_GFHC',
        hos: '0002',
        lev: '0001'
    },
    {
        "catId": "A3",
        "catName": "数码",
        'title': 'B库(29-34)|广州发货仓',
        code: 'F_GFHC',
        hos: '0002',
        lev: '0001'
    },
    {
        "catId": "A4",
        "catName": "健康",
        'title': 'B库(29-34)|广州发货仓',
        code: 'F_GFHC',
        hos: '0002',
        lev: '0001'
    },
    {
        "catId": "A5",
        "catName": "运动机械",
        'title': 'B库(29-34)|广州发货仓',
        code: 'F_GFHC',
        hos: '0002',
        lev: '0001'
    },

]
const category = [
    {
        "title": "发货仓1",
        children: customCategory
    },
    {
        "title": "发货仓2",
        children: customCategory
    },
    {
        "title": "发货仓3",
        children: customCategory
    },
    {
        "title": "发货仓4",
        children: customCategory
    },
    {
        "title": "发货仓5",
        children: customCategory
    },
    {
        "title": "发货仓6",
        children: customCategory
    },
    {
        "title": "发货仓7",
        children: customCategory
    },
]

const props = defineProps<{
    showRound: {
        state: boolean
    }
}>()
const emit = defineEmits<{
    (
        e: "determine",
        p: any
    ): void;
}>()

const searchValue = ref<string>('')
const WarehouseInfo = ref<any[]>([])
const chooseInfo = ref()

const getWarehouseFun = async () => {
    let params = {
        companyNo: Taro.getStorageSync('btStaff').branchCompanyNo,
        send: true
    }
    const res = await getWarehouse(params)
    console.log(res, 152);
    WarehouseInfo.value = res as unknown as any[]
}

const determine = () => {
    props.showRound.state = false
    emit('determine', chooseInfo.value)

}
const chooseHouse = (t) => {
    chooseInfo.value = t
    radioVal.value = t.warehouseNo
}

onMounted(() => {

    getWarehouseFun()
})
</script>
<style></style>
<style lang="scss">
// @import "xxx";
// @import url(xxx);
.warehousePanel {
    --nut-tabs-vertical-tab-line-color: #0966FF;

    .warehousePanel_title {
        padding: 32rpx 32rpx 0;
    }

    .warehousePanel_search {
        margin-top: 20rpx;
    }

    .warehousePanel_content {
        height: 500px;


        .warehousePanel_content_item_title {}

        .warehousePanel_content_pane_list {
            padding-bottom: 20px;
            margin-bottom: 10px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        }
    }

    .warehousePanel_determine {
        padding: 40rpx 0;
    }
}
</style>